﻿using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;
using System.Data.SqlClient;

using Devart.Data.Oracle;
using Devart.Data.Oracle.Linq;
using Devart.Data.Linq;

namespace ConsoleApplication1
{

  #region Line

  [Table(Name = "LINE")]
  public class Line
  {
    [Column(Name = "TAGNO")]
    public string TagNo;

    [Column(Name = "JOB_NO")]
    public string JobNo;
  }
  #endregion

  public class LineDataContext : Devart.Data.Linq.DataContext
  {
    public Table<Line> Lines;
    
    public LineDataContext(OracleConnection connection) : base(connection) { }
  }
 
  public class Program
  {
    static void Main(string[] args)
    {
      try
      {
        string connectionString = "user id=em; password=em; data source=localdb; persist security info=true";
        //string connectionString = @"Data Source=.\SQLExpress; Initial Catalog=MM; User Id=mm_login; Password=mm";
        OracleConnection connection = new OracleConnection(connectionString);

        LineDataContext context = new LineDataContext(connection);

        var lines = from line in context.Lines
                            select line;

        foreach (var line in lines)
        {
          Console.WriteLine(line.TagNo);
        }

        Console.ReadKey();
      }
      catch (Exception ex)
      {
        throw ex;
      }
    }
  }
}